home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!ues5.cern.ch
- From: Dan Pop <Dan.Pop@cern.ch>
- Newsgroups: comp.lang.c
- Subject: Re: What does the -O option do???!!!
- Date: Mon, 12 Feb 1996 01:13:35 +0100
- Organization: CERN European Lab for Particle Physics
- Message-ID: <9602120013.AA06318@ues5.cern.ch>
- References: <4ehger$cj9@mark.ucdavis.edu> <823827008snz@genesis.demon.co.uk> <4fiphrINNrvr@keats.ugrad.cs.ubc.ca> <9602102332.AA09466@dxmint.cern.ch> <4flhrhINNtj@keats.ugrad.cs.ubc.ca>
- X-NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
- X-Mail2News-Path: mail1.cern.ch!ues5.cern.ch
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
-
- >In article <9602102332.AA09466@dxmint.cern.ch>,
- >Dan Pop <danpop@mail.cern.ch> wrote:
- >>c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- >>
- >>>... as long as it is not hard-coded to treat identifiers like "free" specially.
- >>
- >>A compiler is free to treat identifiers like "free" specially after the
- >>relevant header has been included.
- >>
- >>>If you write your own free() with different semantics, you would not want the
- >>>compiler messing with that.
- >>
- >>If you write your own free() you invoke undefined behaviour and you can't
- >>expect the compiler to behave in a sensible way. The implementation
- >>namespace is a big taboo in C.
- >
- >Are you serious? What if I'm writing a little embedded kernel that doesn't use
- >anything resembling the standard C library, and I use free() for something
- >quite different?
-
- Could you, please, actually read the standard before continuing to post
- on this thread? You'll find there a clear distinction between freestanding
- and hosted environments.
-
- >This is truly silly. The standard may say one thing, but it's despicable to
- >actually implement a compiler that treats free() specially. There is nothing in
- >the semantics of free() that requires special treatment in order to do its job.
-
- It's not in the semantics, it's in the fact that "free" is in the
- implementation namespace, and, like all the other names there, cannot be
- redefined without invoking undefined behaviour. What's so difficult to
- understand?
-
- >For one thing, malloc() is far from a perfect allocation scheme, so why give it
- >preferential treatment? I might design my own library which uses allocation
- >handles, and performs heap compaction, for instance.
-
- You can't implement your own library in ANSI C (unless you use a statically
- allocated heap :-) so the point is moot as far as c.l.c is concerned.
-
- >>>It's just another function, after all.
- >>
- >>No, it isn't. Have a look at the standard.
- >
- >I just had a look at the sources for my standard library. It sure looks like a
- >function to me. (Walks like a duck, quacks like a duck, ... )
-
- Even if it is a function, it is part of the implementation and this is what
- makes it different from the functions defined by your application.
-
- You can't have two different functions with the same name and global scope
- in your program, right? Then why do you expect free() to be different?
- Only because the implementations _you_'ve worked with allowed this?
-
- >I wonder whether the seats of that ANSI commitee were actually populated by
- >programmers.
-
- Is this supposed to be a lame excuse for your ignorance in matters of
- standard C? The members of the ANSI commitee had a little bit more
- experience in matters of programming and on a little bit more platforms
- than you.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-